import commonData from "../../api/data"
import commonApi from "../../api/commonApi"
import logApi from "../../api/logApi"
import httpUtil from "../../utils/httpUtil"

Page({
  data: {
    
    rootImagePath: "https://h5.sx2b2c.com/images/shengxin_tingche_mini/zfb/longbao_shengxinka/tcq/",
    isShowAgreement: false,
    agreementType: 1,
    isShowReceiveYindao: false,
  },
  onLoad(option) {
    logApi.addKeepLog('页面加载传入参数 option' + JSON.stringify(option))
    if (option.a) {
      commonData.setA(option.a)
      let params={
        a:option.a,
        proCode:"LH2511"
      }
      httpUtil.post("/api/tongji/tongji0520", params, res => {
    
      }, err => {
        logApi.addKeepLog('版本号' + commonApi.currentVersion + ',下单发生错误，参数' + JSON.stringify(params) + '。返回：' + JSON.stringify(err))
        messageUtil.closeLoading()
        if (errCallBack) {
          errCallBack(err)
        }
      })
    }
    if (option.param) {
      commonData.setParam(option.param)
    }
    if (option.appid) {
      commonData.setAppid(option.appid)
    } 

    if (option.openid) {
      commonData.setOpenid(option.openid)
    }
  
  
    // 有问题无法使用，先放放，让使用方传入 commonApi.initOpenid()
  },
  showQuanyiReceiveYindao() {
    this.setData({
      isShowReceiveYindao: true
    })
  },
  closeReceiveYinDao() {
    this.setData({
      isShowReceiveYindao: false
    })
  },
  showAgreementHandler(e) {
   console.log(111)
    this.setData({
      agreementType: parseInt(e.target.dataset.attr),
      isShowAgreement: true
    })
  },
  agreementOkHandler() {
    this.setData({
      isShowAgreement: false
    })
  },
  gotoMini() {
    my.navigateToMiniProgram({
      appId: '2021004135681441',
      path: 'pages/keeplq/keeplq',
      success: function (res) {
        console.log('跳转小程序成功', res);
      },
      fail: function (err) {
        console.log('跳转小程序失败', err);
      }
    });
  },
  gotoPage(pageUrl) {
    my.navigateTo({
      url: pageUrl
    })
  },
  telHandler() {
    my.makePhoneCall({
      number: '4008825010',

    });
  }
});